package com.gcit.seniorWish.web.modular.report.controller;

import com.gcit.seniorWish.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.gcit.seniorWish.web.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.gcit.seniorWish.web.common.persistence.model.SeniorStatisticsReport;
import com.gcit.seniorWish.web.modular.report.service.ISeniorStatisticsReportService;

/**
 * 上报信息控制器
 *
 * @author fengshuonan
 * @Date 2018-03-25 10:32:53
 */
@Controller
@RequestMapping("/seniorStatisticsReport")
public class SeniorStatisticsReportController extends BaseController {

    private String PREFIX = "/report/seniorStatisticsReport";

    @Autowired
    private ISeniorStatisticsReportService seniorStatisticsReportService;

    /**
     * 跳转到上报信息首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/seniorStatisticsReport.html";
    }

    /**
     * 跳转到添加上报信息
     */
    @RequestMapping("/seniorStatisticsReport_add")
    public String seniorStatisticsReportAdd() {
        return PREFIX + "/seniorStatisticsReportAdd.html";
    }

    /**
     * 跳转到修改上报信息
     */
    @RequestMapping("/seniorStatisticsReport_update/{seniorStatisticsReportId}")
    public String seniorStatisticsReportUpdate(@PathVariable Integer seniorStatisticsReportId, Model model) {
        SeniorStatisticsReport seniorStatisticsReport = seniorStatisticsReportService.selectById(seniorStatisticsReportId);
        model.addAttribute("item",seniorStatisticsReport);
        LogObjectHolder.me().set(seniorStatisticsReport);
        return PREFIX + "/seniorStatisticsReportInfo.html";
    }

    /**
     * 获取上报信息列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return seniorStatisticsReportService.selectList(null);
    }

    /**
     * 新增上报信息
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(SeniorStatisticsReport seniorStatisticsReport) {
        seniorStatisticsReportService.insert(seniorStatisticsReport);
        return super.SUCCESS_TIP;
    }

    /**
     * 删除上报信息
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer seniorStatisticsReportId) {
        seniorStatisticsReportService.deleteById(seniorStatisticsReportId);
        return SUCCESS_TIP;
    }

    /**
     * 修改上报信息
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(SeniorStatisticsReport seniorStatisticsReport) {
        seniorStatisticsReportService.updateById(seniorStatisticsReport);
        return super.SUCCESS_TIP;
    }

    /**
     * 上报信息详情
     */
    @RequestMapping(value = "/detail/{seniorStatisticsReportId}")
    @ResponseBody
    public Object detail(@PathVariable("seniorStatisticsReportId") Integer seniorStatisticsReportId) {
        return seniorStatisticsReportService.selectById(seniorStatisticsReportId);
    }
}
